{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "723e1816-55c1-4f62-ace7-6d3e62c65876",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "92e3ee4e-95b2-453c-8656-27b49225b1f9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 0  1  2  3  4  5]\n",
      " [ 6  7  8  9 10 11]\n",
      " [12 13 14 15 16 17]\n",
      " [18 19 20 21 22 23]]\n"
     ]
    }
   ],
   "source": [
    "n=np.arange(24).reshape(4,6)\n",
    "print(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "238f4b1d-c584-4177-abf3-9c4f2f552f94",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 0  6 12 18]\n",
      " [ 1  7 13 19]\n",
      " [ 2  8 14 20]\n",
      " [ 3  9 15 21]\n",
      " [ 4 10 16 22]\n",
      " [ 5 11 17 23]]\n"
     ]
    }
   ],
   "source": [
    "# 转置\n",
    "n1=n.T\n",
    "print(n1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "daf81f46-adb0-4d42-9d8d-022386415462",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 0  6 12 18]\n",
      " [ 1  7 13 19]\n",
      " [ 2  8 14 20]\n",
      " [ 3  9 15 21]\n",
      " [ 4 10 16 22]\n",
      " [ 5 11 17 23]]\n"
     ]
    }
   ],
   "source": [
    "n2=n.transpose()\n",
    "print(n2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "d5c10ee5-5f7c-4879-9d98-a70b898db6b9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[['A' '100']\n",
      " ['B' '200']\n",
      " ['C' '300']\n",
      " ['D' '400']\n",
      " ['E' '500']]\n"
     ]
    }
   ],
   "source": [
    "# 转置练习\n",
    "n=np.array([['A',100],['B',200],['C',300],['D',400],['E',500]])\n",
    "print(n)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "b92ab5ec-f069-44e3-8367-24baa8aa6054",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[['A' 'B' 'C' 'D' 'E']\n",
      " ['100' '200' '300' '400' '500']]\n"
     ]
    }
   ],
   "source": [
    "n3 = n.T\n",
    "print(n3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4d203763-9eb5-40fd-8a67-90d425737e9d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "aad479e4-f1a6-429c-95b7-5c803d8ca598",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
